/************************************************************************************
**  
* @copyright (c) 2015-, Technology Co., LTD. All Right Reserved.
*
*************************************************************************************/
/**
* @file     duye_cap_service_base.h
* @version     
* @brief      
* @author   
* @date     2013-01-08
* @note 
*
*  1. 2018-01-08 created this file
* 
*/
#pragma once

#include <string>
#include <vector>
#include <duye_thread.h>

#include <duye_cap_object.h>
#include <duye_cap_packet.h>
#include <duye_cap_filter.h>

namespace duye {

/**
 * @brief data service component type
 */
typedef enum {
	DS_LINKLAYER = 0,
	DS_NETLAYER,
	DS_TCP,
	DS_UDP,
	DS_HTTP,
	DS_MAX_NUM
} DataServiceType;

typedef std::vector<DataServiceType> DataServiceTypeVector;

/** 
 * @brief service base class
 */
class CapService : public ThreadTask {
public:
	virtual ~CapService() {}

	virtual bool start() = 0;
	virtual bool stop() = 0;

	// implementation sys::ThreadTask interface
	virtual bool run() = 0;
};

/**
 * @brief data service listener interface
 */
class DataServiceListener : public CapObject {
public:
	virtual ~DataServiceListener() {}
};

/**
 * @brief data service bass class
 */
class CapDataService : public CapService {
public:
    CapDataService() {}
    
    /**
     * @brief constructor
     * @param [in] name : service name
     */    
    CapDataService(const std::string& name) : m_name(name) {}
    virtual ~CapDataService() {}

    // implementation CapService interface
	virtual bool start() = 0;
    // implementation CapService interface
	virtual bool stop() = 0;  

	// implementation CapService interface
	virtual bool run() = 0;	

    /**
     * @brief add listener
     * @param [input] listener : data service listener
     */
    virtual bool addListener(DataServiceListener* listener, const FilterRule* filterRule = NULL) = 0;
    
    /**
     * @brief delete listener
     * @param [input] listener : data service listener
     */
    virtual bool delListener(DataServiceListener* listener) = 0;
    
    /**
     * @brief set/get service name
     * @return service name
     */
    const std::string& name() const { return m_name; }

private:
    std::string m_name;
};

}
